<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <style type="text/css">
        table {border-collapse: collapse; font-size: 14px; width: 80%; margin: auto;}
        table, th, td {border: 1px solid darkslategray;padding: 10px}
    </style>
</head>
<body>
<div style="text-align: center">
    <!--提示栏-->
    <h1 style="color: chocolate">百枝商品运营中心管理后台</h1>
    <a th:href="@{/login/toLogin}">退出登录</a>
    <span style="color: darkslategray; font-size: 25px">欢迎<span th:text="${session.login.loginName}"></span>使用!</span><br>
    <hr style="color: olivedrab"/>
    <table class="list"><!--style="font-family: 楷体;font-size: 25px"-->
        <tr>
            <td>名称</td>
            <td>类型</td>
            <td>介绍</td>
            <td>生产日期</td>
            <td>库存</td>
            <td>当前状态</td>
            <td colspan="4">操作
                <a style="font-size: small" th:if="${#lists.contains(session.login.functionId,1)}" th:href="@{/shop/toInsert}">添加</a>
            </td>
        </tr>
        <tr th:each="shop : ${shopList}">
            <td th:text="${shop.sname}"></td>
            <td th:text="${shop.type}"></td>
            <td th:text="${shop.introduce}"></td>
            <td th:text="${#dates.format(shop.createTime,'yyyy-MM-dd')}"></td>
            <td th:text="${shop.stock}"></td>
            <td th:text="${shop.cname}"></td>

            <!--操作-->
            <td>
                <!-- 运营角色--增/删/改/启用/提交审核 -->
                <a th:if="${#lists.contains(session.login.functionId,2) && shop.state!=1}" th:href="@{/shop/toUpdate(sid=${shop.sid})}">修改</a>
                <a th:if="${#lists.contains(session.login.functionId,3) && shop.state!=1}" th:href="@{/shop/deleteBySid(sid=${shop.sid})}">删除</a>
                <a th:if="${shop.state eq 0 && #lists.contains(session.login.functionId,1)}" th:href="@{/user/toEnable(sid=${shop.sid})}">启用</a>
                <a th:if="${shop.state eq 1}" th:href="@{/user/submitForReview(sid=${shop.sid})}">提交审核</a>
                <!-- 商品中心管理员--审核通过/审核失败 上架 下架 -->
                <a th:if="${#lists.contains(session.login.functionId,6) && shop.state==3}" th:href="@{/user/Approved(sid=${shop.sid})}">审核通过</a>
                <a th:if="${#lists.contains(session.login.functionId,6) && shop.state==3}"  href="#" th:onclick="auditFailed([[${shop.sid}]])"  id="auditFailed">审核失败</a>
                <a th:if="${#lists.contains(session.login.functionId,7) && shop.state==5 || shop.state==9}" th:href="@{/user/toGrounding(sid=${shop.sid})}">上架</a>
                <a th:if="${#lists.contains(session.login.functionId,8) && shop.state==7}" th:href="@{/user/offTheShelf(sid=${shop.sid})}">下架</a>
            </td>

        </tr>
    </table>
</div>
</body>
<script type="text/javascript">
    function auditFailed(sid){
        //alert(sid);
        errorEeason = prompt("请输入审核失败的原因：","");
        //alert(errorEeason);
        window.location.href="http://localhost:8081/user/auditFailed?sid="+sid+"&errorReason="+errorEeason;
    }
</script>
</html>